package run;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import analisis.InterproceduralKInfiniteAnalysis;
import analisis.IntraProceduralAnalysis;
import analisis.SuperGraph;
import soot.Body;
import soot.PhaseOptions;
import soot.Scene;
import soot.SootClass;
import soot.SootMethod;
import soot.jimple.toolkits.callgraph.CHATransformer;
import soot.options.Options;
import soot.toolkits.graph.BriefUnitGraph;
import soot.toolkits.graph.UnitGraph;

public class Main {

    private static final String claseMetodoAnalizado = "run.Test1";
    private static final String metodoAnalizado = "test_1";

    public static void main(String[] args) {

        Options.v().set_keep_line_number(true);
        PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

        Options.v().set_main_class(claseMetodoAnalizado);
        SootClass c = Scene.v().loadClassAndSupport(claseMetodoAnalizado);
        c.setApplicationClass();

        CHATransformer.v().transform();

        SootMethod m = c.getMethodByName(metodoAnalizado);
        Body b = m.retrieveActiveBody();
        System.out.println(b.toString());
        UnitGraph g = new BriefUnitGraph(b);
        System.out.println("Grafo:\n" + g.toString());
        System.out.println("================= INICIO DEL ANALISIS INTRAPROCEDURAL =================");
        IntraProceduralAnalysis intra = new IntraProceduralAnalysis(g, null, null, null, null);
        System.out.println("Resultado Analisis Intraprocedural");
        System.out.println(intra.getResult().toString());
        System.out.println("================= FIN DEL ANALISIS INTRAPROCEDURAL =================");
        System.out.println("================= INICIO DEL ANALISIS INTERPROCEDURAL =================");
        InterproceduralKInfiniteAnalysis inter = new InterproceduralKInfiniteAnalysis("run.Test1", "test_1");
        System.out.println("Resultado Analisis Interprocedural");
        System.out.println(inter.getResult().toString());
        System.out.println("================= FIN DEL ANALISIS INTRAPROCEDURAL =================");
    }
}
